package com.bt.dmdb.json.converter;

import java.io.IOException;
import org.joda.time.DateTime;
import org.springframework.stereotype.Component;
import com.bt.dmdb.enums.DateFormat;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

@Component
public class JsonDateDeserializer extends JsonDeserializer<DateTime> {

    @Override
    public DateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
        return DateTime.parse(parser.getText(), DateFormat.UI.dtf);
    }
}
